#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
This is the base class of all other classes of the pydlink package. It works as
an abstract class, so you will find some methods that was not implemented here.

Written by Arthur Furlan <arthur.furlan@gmail.com>
"""

import telnetlib

class DLink:
    """ This is the base and abstract class of pydlink package. """

    def __init__(self, address, port):
        """ Initialize the object attributes. """
        self.address,self.port = address,port
        self.connected,self.telnet = False,None

    def __del__(self):
        """ Close the connection. """
        if self.telnet:
            self.telnet.close()
        self.connected = False

    def __str__(self):
        """ Human-readable object representation. """
        status = 'connected' if self.connected else 'not connected'
        return '%s (%s:%d -- %s)' % \
                (self.__class__.__name__, self.address, self.port, status)

    def connect(self, username, password):
        """ Connect on device using the username and password. """
        pass

    def command(self, cmd):
        """ Send a command to the device and return the response. """
        pass
